//
//  YDStockMarketDetailTopView.m
//  PeiZiWangBei
//
//  Created by LK-IOS on 2018/1/19.
//  Copyright © 2018年 LK-IOS. All rights reserved.
//

#import "YDStockMarketDetailTopView.h"
#import "YDStockMarketDiskDataDetailView.h"
#import "YDVerticalKTimeLineView.h"



@interface YDStockMarketDetailTopView()

//大盘详情
@property (nonatomic , weak) YDStockMarketDiskDataDetailView *dataDetailView;

@property (nonatomic , weak) YDVerticalKTimeLineView *KTimeLineView;
@end

@implementation YDStockMarketDetailTopView


-(void)setStockDict:(NSDictionary *)stockDict
{
    _stockDict = stockDict;
    //刷新UI
    if (![stockDict count])return;
    self.dataDetailView.stockDict = stockDict;
}

-(void)setStockCode:(NSString *)stockCode
{
    _stockCode = stockCode;
    if (!stockCode.length)return;
    self.KTimeLineView.stockCode = stockCode;
}

-(void)setStockName:(NSString *)stockName
{
    _stockName = stockName;
    if (!stockName.length)return;
    self.KTimeLineView.stockName = stockName;
    
    
}

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor colorWithHexString:mainGray];
        
        [self dataDetailView];
        
        [self KTimeLineView];
        
        
    }
    return self;
}

+(instancetype)stockMarketDetailTopViewWithFrame:(CGRect)frmae StockDict:(NSDictionary *)stockDict StockName:(NSString *)stockName StockCode:(NSString *)stockCode
{
    YDStockMarketDetailTopView *detailView = [[YDStockMarketDetailTopView alloc] initWithFrame:frmae];
    detailView.stockDict = stockDict;
    detailView.stockName = stockName;
    detailView.stockCode = stockCode;
    return detailView;
}

//大盘详情
-(YDStockMarketDiskDataDetailView *)dataDetailView
{
    if (_dataDetailView == nil) {
        YDStockMarketDiskDataDetailView *dateDetailView = [YDStockMarketDiskDataDetailView stockMarketDiskDataDetailViewWithStockDict:self.stockDict];
        dateDetailView.frame = CGRectMake(0, 0, LKScreenW, isPhoneX ? rateX812(112) : rate750(112));
        [self addSubview:dateDetailView];
        _dataDetailView = dateDetailView;
    }
    return _dataDetailView;
}


/*均线 日K*/
-(YDVerticalKTimeLineView *)KTimeLineView
{
    if (_KTimeLineView == nil) {
        CGFloat timelineViewY = isPhoneX ? rateX812(5) : rate750(5);
        CGRect viewFrame = CGRectMake(0, CGRectGetMaxY(self.dataDetailView.frame) + timelineViewY, LKScreenW, isPhoneX ? rateX812(313) : rate750(313));
        YDVerticalKTimeLineView *KTimeLineView = [YDVerticalKTimeLineView verticalKTimeLineViewInitWithFrame:viewFrame WithStockName:self.stockName StockCode:self.stockCode];
        [self addSubview:KTimeLineView];
        _KTimeLineView = KTimeLineView;
    }
    return _KTimeLineView;
}



@end
